package gov.kqqzyyy.monkey.clinicscreen.mytools;


import java.util.concurrent.TimeUnit;

import gov.kqqzyyy.monkey.clinicscreen.R;
import gov.kqqzyyy.monkey.clinicscreen.service.APIService;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by Monkey on 2017/11/1.
 * Service工具类
 */

public class MyServiceUtil {

    private static final String baseUrl = MyApplication.applicationContext.getString(R.string.default_url1);
//    private static final String newUrl = MyApplication.applicationContext.getString(R.string.new_url);
    private static final OkHttpClient client = new OkHttpClient.Builder()
            .connectTimeout(20, TimeUnit.SECONDS)
            .readTimeout(20, TimeUnit.SECONDS)
            .writeTimeout(20, TimeUnit.SECONDS)
            .build();
    private static final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .client(client)
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();
//    private static final Retrofit newRetrofit = new Retrofit.Builder()
//            .baseUrl(newUrl)
//            .client(client)
//            .addConverterFactory(ScalarsConverterFactory.create())
//            .build();

    private static final APIService apiService = retrofit.create(APIService.class);
//    private static final APIService newApiService = newRetrofit.create(APIService.class);

    public static Call<String> getSystemTimeCall() {
        return apiService.getSystemTime();
    }

    public static Call<String> getClinicAreaCall() {
        return apiService.getClinicArea();
    }

    public static Call<String> getClinicDoctorsCall(String ctrllerID) {
        return apiService.getClinicDoctors(ctrllerID);
    }

    public static Call<String> getClinicPatientsCall(String ctrllerID) {
        return apiService.getClinicPatients(ctrllerID);
    }

    public static Call<String> getCallPatientsCall(String ctrllerID) {
        return apiService.getCallPatients(ctrllerID);
    }

    public static Call<String> doUpdatePatientCall(int id) {
        return apiService.doUpdatePatient(id);
    }

//    public static Call<String> getClinicWarnTextCall(String ctrllerID) {
//        return newApiService.getClinicWarnText(ctrllerID);
//    }

}
